<?php

	class class_template
	{
		
		// Load template with input
		function template_replace($template_name, $input)
			{
				$contents = $this->template_load($template_name);
				$contents = $this->_replace($contents, $input);
				return $contents;			
			}
			
		// Load template without input
		function template_normal($template_name)
			{
				$contents = $this->template_load($template_name);
				return $contents;
			}

			
		// function replace template
		function _replace($contents,$input)
			{
				if(is_array($input))
					{
						foreach($input as $key => $value)
							{
							$contents = str_replace('{'. $key .'}', $value, $contents);
							}
					}
				else
					{
					$contents = str_replace('{1}', $input, $contents);
					}
				return $contents;
			}
			
		// Function load template contents
		function template_load($template_name)
			{
				ob_start();
				include('././template/'.TEMPLATE_NAME. '/tpl_file/' .$template_name. TEMPLATE_EXT);
				$contents = ob_get_contents();
				ob_end_clean();
				return $contents;
			}
		
	}
	
?>